<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<script>
    if (window.parent.window !== window) {
        window.top.location = window.location;
    }
</script>
<body class="hold-transition login-page" style="padding-left:600px;background: white"
      th:style="|background-image: url(@{/img/sc.jpg}); background-repeat: no-repeat; background-size: cover; background-attachment: fixed; margin: 0; |">
<div>
    <a href="http:\\192.168.50.1:7070/" style="position :absolute;left: 70px;top: 30px; ">
        <img th:src="@{/img/goback.png}" style="width: 50px;height: 50px;"/>
    </a>
</div>
<div class="row text-center" style="margin-left: 19px; margin-top: 100px;">
    <img th:src="@{/img/logo.png}" width="138px" height="88px" style="vertical-align: middle">
    <h1 style="  font-size: 56px;vertical-align: middle;"><b style="color:#000000; -webkit-text-stroke: 2px black;">辽宁忠旺机械设备制造有限公司</b></h1>
</div>
<div class="login-box" style=" margin-top: 32px">

    <div class="login-logo" style="margin-left: 38px;">
        <b th:if="${profile == 'test'}" style="color: red; font-weight: bold;font-size: 60px; -webkit-text-stroke: 1px black;">(测试)</b>
        <br th:if="${profile == 'test'}">
        <b th:if="${profile == 'dev'}" style="color: red; font-weight: bold;font-size: 60px; -webkit-text-stroke: 1px black;">(开发)</b>
        <br th:if="${profile == 'dev'}">
        <b style="color: #000000; -webkit-text-stroke: 1px black;">生产管理系统</b>
    </div>
    <div class="login-box-body" style="margin-left: 38px;">
        <p class="login-box-msg">登录</p>

        <form id="userForm" th:action="@{/login}" method="post">
            <div class="form-group has-feedback">
                <input type="text" class="form-control" name="account" placeholder="请输入帐号">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="pwd" class="form-control" placeholder="请输入密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-12" style="padding: 0px">
                    <button id="btn_login" type="button" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div th:include="include :: footer"></div>
<script>

    function getParam(paramName) {
        var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }

    $(function () {

        if (getParam("kickOut") === 1) {
            js.modal.alert("您的帐号在其它地点登录，如果不是您本人操作，请及时修改密码！")
        }

        /**
         * 验证初始化
         */
        js.validate.init("userForm", {
            fields: {
                userName: {
                    validators: {
                        notEmpty: {
                            message: '请输入帐号'
                        }
                    }
                },
                pwd: {
                    validators: {
                        notEmpty: {
                            message: '请输入密码'
                        }
                    }
                }
            }
        });

        /**
         * 执行登录
         */
        $("#btn_login").click(function () {
            js.validSubmit({
                formId: "userForm",
                url: ctx + "login",
                data: new FormData($("#userForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        location.href = ctx + "index";
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        });

        /**
         * 回车登录
         */
        js.enter("btn_login");
    })

</script>
</body>
</html>
